<?php

namespace app\common\model\other;
use think\Model;
use fast\Tree;
class StudyCategory extends Model
{

    

    

    // 表名
    protected $name = 'study_category';


    public function getCreatetimeAttr($value)
    {
        $status = date('Y-m-d', $value);
        return $status;
    }


    /**
     * 读取指定ID下子分类
     * @param string $type   指定类型
     * @param string $status 指定状态
     * @return array
     */
    public static function getList()
    {

        $tree = Tree::instance();
        $tree->init(collection(self::where(function ($query)  {
            $query->where('status', '=', 'normal');
        })->order('weigh', 'desc')->field('id,name,createtime,image,pid')->select())->toArray(), 'pid');
        $list= $tree->getTreeArray(0);
        return $list;

        return $list;
    }





}
